#pragma once
#include <mutex>
#include <iostream>
template <class T>
class Singleton
{
public:
    static T& GetInstance()
    {
        static T instance;  // magic static，确保线程安全并初始化
        return instance;
    }

private:
    Singleton() = default;
    Singleton(const Singleton&) = delete;
    Singleton& operator=(const Singleton&) = delete;
    ~Singleton() = default;
};

class A
{
public:
    A()
    {
        Init();
    }
    void Init()
    {
        std::cout << "A" << std::endl;
    }

};
int main()
{
    Singleton<A>::GetInstance().Init();
    return 0;
}
